package cn.com.utt.common.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import cn.com.utt.common.vo.CustomColumn;

public interface CustomColumnMapper {
	@Select("SELECT * FROM custom_column where table_name=#{tableName} and user_id=#{userId} order by order_num")
	@Results({  
		@Result(id=true, column="id", property="id"),  
		@Result(column="user_id", property="userId"),  
		@Result(column="table_name", property="tableName"),  
		@Result(column="col", property="column"),
		@Result(column="order_num", property="order") 
	})  
	List<CustomColumn> queryByTable(@Param("tableName")String tableName,@Param("userId")Long userId);
	@Delete("DELETE FROM custom_column where table_name=#{tableName} and user_id=#{userId}")
	void deleteAll(@Param("tableName")String tableName,@Param("userId")Long userId);
	@Insert("insert into custom_column(table_name,user_id,col,order_num)values(#{tableName}, #{userId},#{column},#{order})")
	void save(CustomColumn column);
	
	@Delete("DELETE FROM custom_column where user_id=#{userId}")
	void deleteByUserId(@Param("userId")long userId);
}
